package com.sqx.modules.userCertification.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.userCertification.entity.UserCertification;
import com.sqx.modules.userCertification.service.IUserCertificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sqx.common.utils.Result;
import org.springframework.web.bind.annotation.RestController;

/**
 * 实名认证表
 *
 * @author wuchang
 * @since 2023-07-25
 */
@RestController
@RequestMapping("/app/userCertification/")
@Api(value = "实名认证-用户端", tags = {"实名认证-用户端"})
public class UserCertificationController {
    @Autowired
    private IUserCertificationService iUserCertificationService;

    /**
     * 新增|修改实名认证表
     */
    @Login
    @ApiOperation("新增|修改实名认证")
    @PostMapping("saveUserCertification")
    public Result saveUserCertification(@RequestAttribute("userId") Long userid, UserCertification userCertification) {
        userCertification.setUserId(userid);
        return iUserCertificationService.saveUserCertification(userCertification);
    }
    @Login
    @ApiOperation("获取我的实名认证信息")
    @PostMapping("getMyCertification")
    public Result getMyCertification(@RequestAttribute("userId") Long userid){
        return Result.success().put("data", iUserCertificationService.getOne(new QueryWrapper<UserCertification>().eq("user_id", userid)));
    }



}
